Net User Command (Examples, Options, Switches, & More) 您所在的位置:网站首页 win7 net 48 Net User Command (Examples, Options, Switches, & More)

Net User Command (Examples, Options, Switches, & More)

2023-03-17 04:35| 来源: 网络整理| 查看: 265

Additional Net User Command Options Item Explanation /active:{yes | no} Use this switch to active or deactivate the specified useraccount. If you don't use the /active option, the net user assumes yes. /comment:"text" Use this option to enter a description of the account. A maximum of 48 characters is allowed. The text entered using the /comment switch is viewable in the Description field in a user's profile in Users and Groups in Windows. /countrycode:nnn This switch is used to set a country code for the user, which determines the language used for error and help messages. If the /countrycode switch isn't used, the computer's default country code is used: 000. /expires:{date | never} The /expires switch is used to set a specific date (see below) in which the account, not the password, should expire. If the /expires switch isn't used, never is assumed. date (with /expires only) If you choose to specify a date then it must be in mm/dd/yy or mm/dd/yyyy format, months and days as numbers, fully spelled out, or abbreviated to three letters. /fullname:"name" Use the /fullname switch to specify the real name of the person using the username account. /homedir:pathname Set a pathname with the /homedir switch if you want a home directory other than the default2. /passwordchg:{yes | no} This option specifies whether this user can change his or her own password. If /passwordchg is not used, the net user assumes yes. /passwordreq:{yes | no} This option specifies whether this user is required to have a password at all. If this switch isn't used, yes is assumed. /logonpasswordchg:{yes | no} This switch forces the user to change his or her password at the next logon. Net user assumes no if you don't use this option. The /logonpasswordchg switch is not available in Windows XP. /profilepath:pathname This option sets a pathname for the user's logon profile. /scriptpath:pathname This option sets a pathname for the user's logon script. /times:[timeframe | all] Use this switch to specify a timeframe (see below) that the user can log on. If you don't use /times then net user assumes that all times are okay. If you do use this switch, but don't specify either timeframe or all, then net user assumes that no times are okay and the user is not allowed to log on. timeframe (with /times only) If you choose to specify a timeframe you must do so in a particular way. Days of the week must be spelled out completely or abbreviated in MTWThFSaSu format. Times of day can be in a 24-hour format, or 12-hour format using AM and PM or A.M. and P.M. Periods of time should use dashes, day and time should be separated by commas and day/time groups by semicolons. /usercomment:"text" This switch adds or changes the User Comment for the specified account. /workstations:{computername[,...] | *} Use this option to specify the hostnames of up to eight computers that the user is allowed to log on to. This switch is really only useful when used with /domain. If you don't use /workstations to specify allowed computers then all computers (*) is assumed.

You can store the output of whatever is shown on the screen after running the net user command by using a redirection operator. See How to Redirect Command Output to a File for instructions.

[2] The default home directory is C:\Users\\ in Windows 10, Windows 8, Windows 7, and Windows Vista. In Windows XP, the default home directory is C:\Documents and Settings\\. For example, if the user account on a Windows 8 tablet is named "Tim," the default home directory created when the account was the first setup was C:\Users\Tim\.

Net User Command Examples

This first example of the net user command shows that at its simplest form, it will produce a list of all the users on the computer, much like this:

Administrator            DefaultAccount           Extra Guest                    jonfi                    WDAGUtilityAccount

This computer has over a dozen user accounts, so they're separated into multiple columns.

net user administrator

In the above net user example, the command produces all the details on the administrator user account. Here's an example of what might display:

User name                    Administrator Full Name Comment                      Built-in account for administering the computer/domain User's comment Country/region code          000 (System Default) Account active               No Account expires              Never Password last set            8/24/2020 1:21:25 PM Password expires             Never Password changeable          8/24/2020 1:21:25 PM Password required            Yes User may change password     Yes Workstations allowed         All Logon script User profile Home directory Last logon                   11/9/2021 11:48:13 AM Logon hours allowed          All Local Group Memberships      *Administrators Global Group memberships     *None

As you can see, all the details for that user on this computer are listed.

net user rodriguezr /times:M-F,7AM-4PM;Sa,8AM-12PM

Here's an example where the rodriguezr account is having its login days and times changed.

net user nadeema r28Wqn90 /add /comment:"Basic user account." /fullname:"Ahmed Nadeem" /logonpasswordchg:yes /workstations:jr7tww,jr2rtw /domain

We thought we'd throw the kitchen sink at you with this one. This is the kind of net user application you might never do at home, but you might very well see in a script published for a new user by the IT department in a company.

Here, we're setting up a new user account with the name nadeema, and setting the initial password as r28Wqn90. This is a standard account in our company, which we note in the account itself [/comment:"Basic user account."], and is the new Human Resources executive, Ahmed [/fullname:"Ahmed Nadeem"].

We want Ahmed to change his password to something he won't forget, so we want him to set his own the first time he logs on [/logonpasswordchg:yes]. Also, Ahmed should only have access to the two computers in the Human Resources office [/workstations:jr7twwr,jr2rtwb]. Finally, our company uses a domain controller [/domain], so Ahmed's account should be set up there.

As you can see, the net user command can be used for a lot more than simple user account adds, changes, and removals. We configured several advanced aspects of Ahmed's new account right from Command Prompt.

net user nadeema /delete

Now, we'll finish off with an easy one. Ahmed [nadeema] didn't work out as the latest HR member, so he was let go, and his account removed [/delete].

Net User Related Commands

The net user command is a subset of the net command and so is similar to its sister commands like net use, net time, net send, net view, etc.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有